

<template>
  <div>
    <!-- <el-empty description="发挥一下，让产品搞一搞" /> -->
    <div class="echartBox">
      <div class="echartLeftBox">
        <div class="leftInto">
          <div class="titleBox">
            <div class="title">职务数量</div>
            <div class="linkBox">
              <el-link type="primary" :underline="false">更多<el-icon><ArrowRight /></el-icon></el-link>
            </div>
          </div>
          <div class="circleOutBox">
            <div class="circleInBox">
              <div class="circleTitle">职务数量/在职数量</div>
              <div id="circle1" class="circle"></div>
            </div>
            <div class="circleInBox">
              <div class="circleTitle">本月任免信息/职务数量</div>
              <div id="circle2" class="circle"></div>
            </div>
          </div>
        </div>
        <div class="leftInto">
          <div class="titleBox">
            <div class="title">活动数据</div>
            <div class="linkBox">
              <el-link type="primary" :underline="false">更多<el-icon><ArrowRight /></el-icon></el-link>
            </div>
          </div>
          <div class="circleOutBox">
            <div class="circleInBox">
              <div class="circleTitle">护照管理</div>
              <div id="circle3" class="circle"></div>
            </div>
            <div class="circleInBox">
              <div class="circleTitle">出入境管理</div>
              <div id="circle4" class="circle"></div>
            </div>
          </div>
        </div>
      </div>
      <div class="echartRightBox">
        <div class="linePicBox">
          <div class="lineTitleBox">
            <div class="lineTitle">体系完整度解析</div>
            <div class="lineTitleDesBox">
              <div class="lineDesIn">
                <div class="lineDesTitle">人员数量</div>
                <div class="lineDes">299</div>
              </div>
              <div class="lineDesLine"></div>
              <div class="lineDesIn">
                <div class="lineDesTitle">干部数量</div>
                <div class="lineDes">299</div>
              </div>
              <div class="lineDesLine"></div>
              <div class="lineDesIn">
                <div class="lineDesTitle">空闲职位</div>
                <div class="lineDes">299</div>
              </div>
              <div class="lineDesLine"></div>
              <div class="lineDesIn">
                <!-- 小于80红色 -->
                <div class="lineDesTitle">体系完整度</div>
                <div class="lineDes" :class="tixi<80?'lineDes1':'lineDes2'">88%</div>
              </div>
            </div>
          </div>
          <div class="linePicInBox">
            <div id="line"></div>
          </div>
        </div>
        <div class="tableBoxConsole">
          <tableList
              :tableData="tableData"
              :tableConfig="tableConfig"
              @doit="tableDoit"
          />
        </div>
      </div>
    </div>
  </div>
</template>
<script lang="ts">
import {drawCircle} from './echart/console/circle'
import {drawLine} from './echart/console/line'
import tableList from '@/components/TableList.vue'
import {table_config} from './consoleTableConfig.js'
import { getPostList} from "@/api/system/post.ts";
import {getUserList} from "@/api/system/user.ts";
export default {
  components:{
    tableList
  },
  data(){
    return{
      tableConfig:{},
      tableData:[]
    }
  },
  methods:{
    tableDoit(e){
      console.log(e)
    },
    async getList(){
      this.tableConfig = table_config()
      let page = {
        pageNum: this.tableConfig.pageNum,
        pageSize: this.tableConfig.pageSize,
      }
      //数据初始化
      let postList = await getPostList(page)
      let r = await getUserList(page)
      this.tableData = r.data.map((item) => {
        item.showList = []
        item.postIdsValue = []
        item.postIds.map((itemIn)=>{
          postList.data.map((itemInto)=>{
            if(itemInto.postId == itemIn){
              item.postIdsValue.push(itemInto.postName)
              item.showList.push({label:itemInto.postName,id:itemIn})
            }
          })
        })
        
        return item
      });
    }
  },
  mounted(){
    this.getList()
    // 基于准备好的dom，初始化echarts实例
    setTimeout(()=>{
      drawCircle({color:'#0079fe'},document.getElementById('circle1'));
      drawCircle({color:'#ff0062'},document.getElementById('circle2'));
      drawCircle({color:'#0079fe'},document.getElementById('circle3'));
      drawCircle({color:'#ff0062'},document.getElementById('circle4'));
      drawLine({},document.getElementById('line'));
    },500)
  }
}

</script>
<style>
.tableBoxConsole .header{
  color: #409eff;
}
</style>
<style scoped lang="scss">
div{
  box-sizing: border-box;
}
.echartBox{
  display: flex;
  padding: 0 20px;
}
.echartLeftBox{
  width: 45%;
}
.echartRightBox{
  padding-left: 20px;
  flex: 1;
}
.linePicBox{
  border: 1px solid #eee;
  border-radius: 4px;
  height: 430px;
  padding-top: 20px;
  display: flex;
  flex-direction: column;
}
.lineTitleBox{
  display: flex;
  padding:0 20px;
  align-items: center;
}
.lineTitleDesBox{
  flex: 1;
}
.lineTitleDesBox{
  display: flex;
  justify-content: center;
}
.lineDesIn{
  padding: 0 20px;
}
.lineDesTitle{
  text-align: center;
}
.lineDes{
  text-align: center;
  color: #59d538;
}
.lineDes1{
  color: red;
}
.lineDes2{
  color: #333;
}
.linePicInBox{
  flex: 1;
}
#line{
  width: 100%;
  height: 100%;
}
.leftInto{
  height: 430px;
  display: flex;
  flex-direction: column;
}
.titleBox{
  display: flex;
  padding-top: 20px;
  
  justify-content: space-between;
  align-items: center;
}
.title{
  font-size: 18px;
}
.circleOutBox{
  display: flex;
  flex: 1;
  justify-content: center;
  padding: 20px;
  padding-bottom: 0;
  margin-top: 20px;
  align-items: center;
  border: 1px solid #eee;
  border-radius: 4px;
}
.circleTitle{
  text-align: center;
}
.circle{
  width: 250px;
  height: 200px;
}
.tableBoxConsole{
  margin-top: 20px;
}
.link{
  color: #409eff;
}
</style>